package com.bl.student.service.biz.school.impl;

import com.bl.student.dao.repository.SchoolRepository;
import com.bl.student.service.biz.BaseService;
import com.bl.student.service.biz.school.SchoolService;
import com.bl.student.service.vo.ListVo;
import lombok.extern.log4j.Log4j2;
import org.assertj.core.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by yujingyi on 2018/5/6.
 */
@Log4j2
@Service
public class SchoolServiceImpl extends BaseService implements SchoolService {

    @Autowired
    SchoolRepository schoolRepository;

    public ListVo getSchoolByCountyIdAndSchoolname(int countyId, String schoolname) {
        if (Strings.isNullOrEmpty(schoolname)) {
            return handleList(schoolRepository.findByCountyId(countyId));
        } else {
            return handleList(schoolRepository.findByCountyIdAndSchoolnameLike(countyId, "%" + schoolname + "%"));
        }
    }
}
